

import DefaultPlatform from "./DefaultPlatform";
import Platform = require('./Platform');
import WebAndroidPlatform from './WebAndroidPlatform';
import WebIOSPlatform from './WebIOSPlatform';
import WXGamePlatform from './WXGamePlatform';
import IOSPlatform from "./IOSPlatform";
import FBInstantPlatform from "./FBInstantPlatform";

export default class PlatformUtil {

    public static platform: Platform;

    public static init() {
      
        switch (cc.sys.platform) {
            case cc.sys.WECHAT_GAME:
            console.log("微信小游戏平台")
            this.platform =  new WXGamePlatform();
                break;
            case cc.sys.ANDROID:
            this.platform = new WebAndroidPlatform();
                break;
            case cc.sys.IPHONE:
            case cc.sys.IPAD:
            console.log("ios平台")
            this.platform = new IOSPlatform();
                break;
            default:
            if (cc.sys.isBrowser) {
            switch (cc.sys.os) {
                case cc.sys.OS_ANDROID:
                    this.platform = new FBInstantPlatform();
                    break;
                case cc.sys.OS_IOS:
        
                    this.platform = new FBInstantPlatform();
                    break;
                default:
                console.log("初始化平台",cc.sys.os)
                    this.platform = new FBInstantPlatform();
                    break;
            }
         }else {
            this.platform = new DefaultPlatform();
            }
                break;

            } 
        window['platform'] = this.platform;
    }

}